import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * This class represent to the dump. By bringing any circuit or device is removed from the world.
 * 
 * @author Christian Pérez Zavalija
 * @version 25-Jun-2013
 */
public class Dump extends Actor
{
    private GreenfootImage imgDump;
    
    /**
     * Load the image and displays.
     */
    public Dump()
    {
        imgDump= new GreenfootImage("dump.png");
        setImage(imgDump);
    }
    
    /**
     * If you approach any circuit or device is removed along with all the pins.
     */
    public void act() 
    {
        /*for(Circuit c:circuits)
       removeTouching (c.class);*/
       if(isTouching(Circuit.class)){
           Actor a=getOneIntersectingObject(Circuit.class);
           for(int i=0;i<14;i++)
            ((Circuit)a).eliminate();
           removeTouching (Circuit.class);
       }
       if(isTouching(DipSwitch.class)){
           Actor a=getOneIntersectingObject(DipSwitch.class);
           for(int i=0;i<16;i++)
            ((DipSwitch)a).eliminate();
           removeTouching (DipSwitch.class);
       }
       if(isTouching(Display.class)){
           Actor a=getOneIntersectingObject(Display.class);
           for(int i=0;i<10;i++)
            ((Display)a).eliminate();
           removeTouching (Display.class);
       }
       if(isTouching(LED.class)){
           Actor a=getOneIntersectingObject(LED.class);
           for(int i=0;i<2;i++)
            ((LED)a).eliminate();
           removeTouching (LED.class);
       }
       if(isTouching(PushButton.class)){
           Actor a=getOneIntersectingObject(PushButton.class);
           for(int i=0;i<2;i++)
            ((PushButton)a).eliminate();
           removeTouching (PushButton.class);
       }
    }    
}
